//
//  LXTabBar.m
//  bgms_p
//
//  Created by xiao.zhao@lachesis-mh.com on 16/2/23.
//  Copyright © 2016年 xiao.zhao@lachesis-mh.com. All rights reserved.
//

#import "LXTabBar.h"

@implementation LXTabBar
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //[self addRoundView];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    NSInteger offsetHeight = kScreenHeight > 800 ? 39 : 0;
    self.frame = CGRectMake(0, kScreenHeight - 54 - offsetHeight, kScreenWidth, 54 + offsetHeight);
    [self setBarTintColor:kAppBarColor];
    self.translucent = NO;
    NSInteger itemCount = self.items.count;
    CGFloat itemWidth = self.bounds.size.width / itemCount;
    __block int tempVar = 0;
    [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UIView *subview = obj;
        if ([subview isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            subview.frame = CGRectMake(tempVar * itemWidth, 5, itemWidth, 50);
            if (idx != self.subviews.count - 1) {
                [subview drawAroundViewWithLocation:DrawRight color:kAppLinesColor insets:UIEdgeInsetsMake([LXAutoLength lx_L:5], 0.5, [LXAutoLength lx_L:-15], 0)];
            }
            tempVar ++;
        }
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
